﻿namespace OpenLS.Spreadsheet.Extensibility
{
    public class AllowToDoubleConversionAttribute : ParameterConverterAttribute
    {
        internal override void ConvertImp(ConversionData data)
        {
            if (data.TargetType == typeof(double))
            {
                object value = data.Value;
                if (value is ICell)
                    value = ((ICell)value).Value;
                if (value is int)
                    data.Result = (double)(int)value;
                if (value is float)
                    data.Result = (double)(float)value;
                if (value is decimal)
                    data.Result = (double)(decimal)value;
            }
        }
    }
}